/*************************************************************************
 *************************************************************************
 	 	 	 	 	 	 	M2SMA : PriorityScheduler.h
 *************************************************************************
 *
 	 Copyright (C) 2011
 	 M2SMA enhanced core, Steven Costiou, France
 *
 **************************************************************************
 **************************************************************************
 *
	The Priority Scheduler schedules agents following specific priorities.
	Thus, agents with higher priorities will be scheduled before agents
	with lower priorities.

	A priority is just an integer between 0 and 99. Key priorities are the
	following :

	- ABSOLUTE_PRIORITY 	: 	0
	- VERY_HIGH_PRIORITY	:	1
	- MEDIUM_PRIORITY		:	50
	- LOW PRIORITY			:	99

	The Priority Scheduler is also more efficient as its super class, as
	it uses a given object to know agents it has to schedule, and do not
	create a specific vector at each cycle.

 *
 **************************************************************************
 **************************************************************************
 *
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/
 *
 **************************************************************************
 **************************************************************************/

#ifndef PRIORITYSCHEDULER_H_
#define PRIORITYSCHEDULER_H_

#include "Scheduler.h"

class PriorityScheduler : public Scheduler
{
	public:

		PriorityScheduler();
		~PriorityScheduler();

        /**
         * Adds an agent to the agent lists.
         */
        void addAgentWithPriority(Agent* anAgent, short int aPriority);

        /**
         *  Remove an agent from all data structures, must be called by an Agent.
         */
        void removeAndClearAgent(Agent* anAgent);

        /**
         * Does a scheduling cycle, according to the current scheduling mode.
         */
        void cycle();

	private:

		void initializeAttributes();

		void performPriorityScheduling();

	private:

		map<string, Agent*>* absolutePriorityVector;
		map<string, Agent*>* veryHighPriorityVector;
		map<string, Agent*>* mediumPriorityVector;
		map<string, Agent*>* lowPriorityVector;

};

#endif /* PRIORITYSCHEDULER_H_ */













